import { createStore } from 'vuex';

const store = createStore({
    state: {
        //静态变量
        appName: 'Smart Study',

        //动态变量
        userType: 0, //0为学生 1为教师
        userId: 0,
    },
    mutations: {
        // 如果需要更新
        setUserType(state, newUserType) {
            state.userType = newUserType;
        },
        setUserId(state, newUserId){
            state.userId = newUserId
        }
    },
    actions: {
        // 如果需要通过异步操作来更新
    },
    getters: {
        getAppName: state => state.appName,
        getUserType: state => state.userType,
        getUserId: state => state.userId
    }
});

export default store;
